<div class="layui-side layui-bg-black">
	<div class="layui-side-scroll">
		<#include "/apps/service/include/left.html">
	</div>
</div>
<div class="layui-body">
	<div class="layui-side-scroll">
		<div class="row">
			<div class="col-lg-12">
				<h1 class="site-h1" style="border-top:1px solid #e6e6e6;">
					历史会话<#if agentServiceList??>（${agentServiceList.totalElements}）</#if>
					<span style="float:right;">
						<form class="layui-form" name="search"	action="/service/history/index.html" method="get" style="float: left;margin-right:5px;">
							<div class="layui-form-item">
								<div class="layui-inline" style="margin-right:0px;">
									<div class="layui-input-inline" style="width: auto;margin-right:0px;">
										<label class="layui-form-label" style="width: auto;">用户名：</label>
										<div class="layui-input-inline" style="width: auto;margin-right:0px;">
									      <input type="text" name="username" placeholder="请输入用户名" autocomplete="off" value="${username!''}" class="layui-input ukefu-input">
									    </div>
									</div>
								</div>
								<div class="layui-inline" style="margin-right:0px;">
									<div class="layui-input-inline" style="width: auto;margin-right:0px;">
										<label class="layui-form-label" style="width: auto;">接入渠道：</label>
										<div class="layui-input-inline" style="width: auto;margin-right:0px;">
									      <input type="text" name="channel" placeholder="请输入接入渠道" autocomplete="off" value="${channel!''}" class="layui-input ukefu-input">
									    </div>
									</div>
								</div>
								<div class="layui-inline" style="margin-right:0px;">
									<div class="layui-input-inline" style="width: auto;margin-right:0px;">
									<label class="layui-form-label" style="width: auto;"></label>
										<div class="layui-input-inline" style="width: auto;margin-right:0px;">
											<#assign two=true/>
											<select name="servicetype" id="servicetype"  onchange="deptorservice(this.value)" class="layui-input ukefu-input"   lay-ignore >
												<option value="">-请选择-</option>
												<#if servicetype=="skill">
													<option value="agentno" >服务坐席 </option>
													<option value="skill" selected>技能组 </option>
												<#else>
													<option value="agentno" selected>服务坐席 </option>
													<option value="skill" >技能组 </option>
												</#if>
										    </select>
										    <label  >~</label>
										    <select name="allocation" id="allocation" class="layui-input ukefu-input" lay-ignore>
										    	
											</select>
										</div>
									</div>
								</div>
								<div class="layui-inline" style="margin-right:0px;">
									<div class="layui-input-inline" style="width: auto;margin-right:0px;">
										<label class="layui-form-label" style="width: auto;"></label>
											<div class="layui-input-inline" style="width: auto;margin-right:0px;">
												<select name="servicetimetype" class="layui-input ukefu-input" lay-ignore>
													<option value="logindate">咨询时间</option>
													<#if servicetimetype=="servicetime">
														<option value="servicetime" selected>服务时间</option>
													<#else>
														<option value="servicetime">服务时间</option>
													</#if>
											        
											    </select>
										    </div>
										<label class="layui-form-label" style="width: auto;">=</label>
										<div class="layui-input-inline" style="width: auto;margin-right:0px;">
									      <input name="begin" class="layui-input ukefu-input" placeholder="开始时间" value="${begin!''}" onclick="layui.laydate({elem: this, istime: true, format: 'YYYY-MM-DD hh:mm:ss'})">
									    </div>
										<label class="layui-form-label" style="width: auto;">~</label>
										<div class="layui-input-inline" style="width: auto;margin-right:0px;">
									      <input name="end" class="layui-input ukefu-input" placeholder="结束时间" value="${end!''}" onclick="layui.laydate({elem: this, istime: true, format: 'YYYY-MM-DD hh:mm:ss'})">
									    </div>
									</div>
								</div>
								<div class="layui-inline" style="margin-right:0px;">
									<div class="layui-input-inline" style="width: auto;margin-right:0px;">
										<div class="layui-input-inline" style="width: auto;margin-right:0px;">
									      <button class="layui-btn layui-btn-small layui-btn-primary" style="color:#ffffff;">
											  <i class="layui-icon"></i>
											</button>
									    </div>
									</div>
								</div>
								
							</div>
						</form>
					</span>
				</h1>
				<table class="layui-table" lay-skin="line">
					<thead>
						<tr class="design-sortable-tr">
							<th>用户名</th>
							<th>接入渠道</th>
							<th>服务坐席</th>
							<th>咨询时间</th>
							<th>服务时间</th>
							<th>等待时长</th>
							<th>服务时长</th>
							<th>地域</th>
						</tr>
					</thead>
					<tbody>
						<#if agentServiceList?? && agentServiceList.content?? && agentServiceList.content?size gt 0>
						<#list agentServiceList.content as agentService>
						<tr class="tdHasContorllor design-dropable-td">
							<td class=" first_td_head">
								<a href="/service/online/index.html?userid=${agentService.userid!''}&agentservice=${agentService.id!''}">
								${agentService.username!''}
								</a>
							</td>
							<td>
								${agentService.channel!''}
							</td>
							<td>
								${agentService.agentusername!''}
							</td>
							<td><#if agentService.logindate??>${agentService.logindate?string('yyyy-MM-dd HH:mm:ss')}</#if></td>
							<td>
								<#if agentService.servicetime??>
								${agentService.servicetime?string('yyyy-MM-dd HH:mm:ss')}
								</#if>
							</td>
							<td>
								${(agentService.waittingtime/(1000*60*60))?string('00')}:${((agentService.waittingtime%(1000*60*60))/(1000*60))?string('00')}:${((agentService.waittingtime%(1000*60))/(1000))?string('00')}
							</td>
							
							<td class="minSize ">
								${(agentService.sessiontimes/(1000*60*60))?string('00')}:${((agentService.sessiontimes%(1000*60*60))/(1000*60))?string('00')}:${((agentService.sessiontimes%(1000*60))/(1000))?string('00')}
							</td>
							<td class=" ">${agentService.region!''}</td>
						</tr>
						</#list>
						<#else>
							<tr>
								<td colspan="20" style="height:400px;">
									<div class="ukefu-empty">
										<i class="layui-icon">&#xe63a;</i>
										<div style="">还没有历史会话</div>
									</div>
								</td>
							</tr>
						</#if>
					</tbody>
				</table>

			</div>
		</div>
		<div class="row" style="padding:5px;">
			<div class="col-lg-12" id="page" style="text-align:center;"></div>
		</div>
	</div>
</div>
<script>
	layui.use(['laypage', 'layer'], function(){
		  var laypage = layui.laypage
		  ,layer = layui.layer;
		  
		  laypage({
				cont: 'page'
				,pages: <#if agentServiceList??>${agentServiceList.totalPages}<#else>0</#if> //总页数
				,curr:<#if agentServiceList??>${agentServiceList.number+1}<#else>0</#if>
				,groups: 5 //连续显示分页数
				,jump:function(data , first){
					if(!first){
						location.href = "/service/history/index.html?p="+data.curr ;
					}
				}
		   });
		});
	function deptorservice(data){
		$('#allocation').html("");
		if(data=="agentno"){
			$("#allocation").append("<#if userlist?? ><#list userlist as user ><#if allocation??><option value=\"${user.id}\" selected>${user.uname}</option><#else><option value=\"${user.id}\">${user.uname}</option></#if> </#list> </#if>");
		}else if(data=="skill"){
			$("#allocation").append("<#if deptlist?? ><#list deptlist as dept ><#if allocation??><option value=\"${dept.id}\" selected>${dept.name}</option><#else><option value=\"${dept.id}\">${dept.name}</option> </#if> </#list> </#if>");
		}
	}

</script>
